<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>事件策略模板</title>
    <meta name="decorator" content="nblank"/>
</head>
<body>
<div class="content container">
    <h2 class="page-title">事件策略模板<small>事件策略模板${not empty param.id?'修改':'添加'}</small></h2>
    <section class="widget widget-tabs widget-table-overflow ">
        <header>
            <ul class="nav nav-tabs">
                <li><a href="${ctx}/biz/et/">设备型号列表</a></li>
                <li class="active"><a href="javascript:;">模板${not empty param.id?'修改':'添加'}</a></li>
            </ul>
        </header>
        <div class="body tab-content">
            <form:form id="inputForm" modelAttribute="eventTemplate" action="${ctx}/biz/et/save" method="post" class="form-horizontal">
                <form:hidden path="id"/>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline"><span style="color:red;">*</span>名称:</span></label>
                    <div class="col-sm-4">
                        <form:input path="name" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline"><span style="color:red;">*</span>关键字:</span></label>
                    <div class="col-sm-4">
                        <form:input path="key" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
                        <label id="keyScan" class="error" style="display: none;">关键字重复，请重填</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline"><span style="color:red;">*</span></span>设备类型:</label>
                    <div class="col-sm-4">
                        <form:select path="equipmentId" data-width="auto"  data-style="btn-primary" class="selectpicker">
                            <form:option value="" label="请选择" />
                            <form:options items="${equList}" itemValue="id" itemLabel="name" />
                        </form:select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span class="help-inline">备注:</span></label>
                    <div class="col-sm-4">
                        <form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="form-control input-transparent"/>
                    </div>
                </div>
                <div class="form-actions">
                    <div class="text-align-center">
                        <input id="btnCancel" class="btn btn-default" type="button" style="margin-left: -50px;min-width:100px;" value="返 回" onClick="history.go(-1)"/>
                        <input id="btnSubmit" class="btn btn-primary" style="margin-left:50px;min-width:100px;" type="submit" value="保 存"/>&nbsp;
                    </div>
                </div>
            </form:form>
        </div>
    </section>
  </div>
<script type="text/javascript">
    $(function(){
        <%--function pageLoad() {--%>
            <%--$("#name").focus();--%>
            <%--$('form').on('submit', function(e) {--%>
                <%--e.preventDefault();--%>
                <%--$(this).ajaxSubmit({--%>
                    <%--success:function(result){--%>
                        <%--pxTrigDlg("${ctx}/biz/et");--%>
                    <%--}--%>
                <%--});--%>
            <%--});--%>
        <%--}--%>
        <%--pageLoad();--%>
        $("#inputForm").validate({
            ignore:"",
            invalidFocus:true,
            rules:{
                name:"required",
                key:"required",
                equipmentId:"required"
            },
            messages:{
                equipmentId:{
                    required:"必选信息"
                }
            },
            errorPlacement:function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler:function (form) {
                $(form).find(":submit").attr("disabled",true).attr("value","提交中...");
                $(form).ajaxSubmit(function (result) {
                    switch (result){
                        case "success":
                            Messenger().post("操作成功!");
                            pxTrigDlg("${ctx}/biz/et");
                            break;
                        case "error":
                            $(form).find(":submit").attr("disabled",false).attr("value","提交");
                            $("#keyScan").css("display","block");
                            break;
                    }
                });
            }
        });
    });
</script>

</body>
</html>